/*
 * Integration.h
 *
 *  Created on: Aug 11, 2010
 *      Author: bernardo
 */

#ifndef INTEGRATION_H_
#define INTEGRATION_H_
#include "Dynamics.hpp"
#include "FileValues.hpp"
#include <iostream>
#include <memory>

class Integration {
public:
	Integration() : densFile(NULL), statFile(NULL) {};
	void setDensFile(std::ostream& file) {this->densFile = &file;}
	void setStatFile(std::ostream& file) {this->statFile = &file;}
	void readParameters(std::istream& inFile);
	void writeParameters(std::ostream& outFile);
	template <class iterator> void setV(iterator begin, iterator end);
	template <class iterator> void setD(iterator begin, iterator end);
	inline size_t getNStages() const {return dynamics.getNStages(); }
	void evolution();
	void completionTime(ProbDens<1>&);
private:
	double dPhi, dT, finalT, dTSave;
	std::vector<double> v, D;
	std::ostream *densFile, *statFile;
	size_t nStages;
	FileValues fileValues;
	Dynamics dynamics;
	void prepareDynamics();
};

template <class iterator>
void Integration::setV(iterator begin, iterator end) {
	v.assign(begin,end);
}

template <class iterator>
void Integration::setD(iterator begin, iterator end) {
	D.assign(begin,end);
}
#endif /* INTEGRATION_H_ */
